﻿@using Treca.WebEx.Entity;
@using Treca.Util;
@using EFCore.Sharding; 
@using Treca.Business.Base_SysManage;
@inherits DependencyViewPage 
@using System.Data;
@using Microsoft.AspNetCore.Http;
@using Newtonsoft.Json;
@using Treca.Base_SysManage.Entity;
@{
    Layout = "~/Views/Shared/_Layout_MainForm.cshtml";

    var rownum = this.ViewData["rownum"];
    var guid = this.ViewData["guid"];
    var key = this.ViewData["key"];
    var value = this.ViewData["value"];
    if (rownum.IsNullOrEmpty())
    {
        rownum = -1;
    }
    BaseDataHelper dataHelper = (BaseDataHelper)this.ViewData["listHelper"];
}
<div class="fx-wrapper">
      <form class="form-inline" id="searchForm"   style="width: 800px"> 
         <div class="form-group">             
           <!--   <div class="col-sm-2 input-icon-group"  style="width: 60 % "> 
                @TranslateService.GetTranslate("","System_AddFile","添加文件")
               <div id="WorkerContractImg" style="width:120px;height:104px;overflow:inherit" ></div>
            </div>
            <button type = "button" class="btn btn-info btn-sm" onclick="speech()" );" >
                <i class="glyphicon glyphicon-export" ></i>
                @TranslateService.GetTranslate("","System_SpeechInput","语音输入")
            </button>
            <input type = "file1" id="file1" name ="myfile1" style="display: none" />
      
            <button type = "button" class="btn btn-success btn-sm" onclick="OCRForm()" );" >
                <i class="glyphicon glyphicon-export" ></i>
                @TranslateService.GetTranslate("","System_FormRecognition","表单识别")
            </button>-->

        </div>
    </form>
</div>
<div style="padding:15px;padding-right:45px;">
    <form id="form" class="form-horizontal" role="form">
        
                          <div class="form-group form-group-sm">
                        <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_code","验证码")</label>
                        <div class="col-sm-5">@{
                                        base_selectresource_data dataselectcode = dataHelper.GetDataUrlAll("CleanBG", "d_sms", "code");
                                        if(!dataselectcode.sr.IsNullOrEmpty()&&!dataselectcode.sr.Id.IsNullOrEmpty()){
                                            if( dataselectcode.bs.selecttype=="1")
                                            {
                                                <select id='code' name="code" value="" class="form-control column selectpicker" data-live-search="true"  >
                                                    @foreach (DataRow rows in dataselectcode.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            
                                            }
                                            if( dataselectcode.bs.selecttype=="3")
                                            {
                                                <select id='code' name="code" value="" class="form-control column selectpicker" data-live-search="true" multiple >
                                                    @foreach (DataRow rows in dataselectcode.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            }
                                             if( dataselectcode.bs.selecttype=="2")
                                             {
                                                 string typename = @dataselectcode.sr.tablename.Split('.')[@dataselectcode.sr.tablename.Split('.').Length - 1];
                                                 string areaname = @dataselectcode.sr.tablename.Split('.')[@dataselectcode.sr.tablename.Split('.').Length - 3];
                                                 <input id='code__Name' name='code__Name' value='' onclick='openFormSelect("/@areaname/@typename","@dataselectcode.sr.filedcode,@dataselectcode.sr.filedvalue",this); ' type='text' class='form-control column'  readonly='readonly'/>
                                                 <input id='code' name='code' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                              }
                                             if( dataselectcode.bs.selecttype=="4")
                                             {
                                                 <div id='codeImg' style='width:100%; height:200px; overflow: auto'></div>
                                                 <input id='code__Name' name='code__Name' value='' type='hidden'  class='form-control column'  readonly='readonly'/>
                                                 <input id='code' name='code' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                                  @Html.Raw("<script>\n");
                                                  @Html.Raw("$(function(){\n");
                                                  @Html.Raw("$('#code__Img').html5Uploader({\n");
                                                  @Html.Raw("asyncUpload: true,\n");
                                                  @Html.Raw("uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                                  @Html.Raw($"uploadLimit: {dataselectcode.getPropValue("filenum")},  //上传数量限制，0为不限\n");
                                                  @Html.Raw($"sizeLimit:{dataselectcode.getPropValue("filesize")},    //大小限制，M\n");
                                                  @Html.Raw($"type: '{dataselectcode.getPropValue("filetype")}' //file即可上传文件也可上传图片\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("$('#code__Name').on(' input propertychange',function(){\n");
                                                  @Html.Raw("var urls = $(this).val().split(',');\n");
                                                  @Html.Raw("var ids = $('#code').val().split(',');\n");
                                                  @Html.Raw("$.each(urls, function(index, url){\n");
                                                  @Html.Raw("if(url!='')\n");
                                                  @Html.Raw("$('#code__Img').html5Uploader('insertItemNew',{src:url,id:ids[index]});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("</script>\n");
                                              }
                                        }
                                        else {
                                        <input id='code' name="code"  maxlength="50" value="" type="text" class="form-control column" >}}
                                </div>
                            </div>
                          <div class="form-group form-group-sm">
                        <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_type","验证码类型")</label>
                        <div class="col-sm-5">@{
                                        base_selectresource_data dataselecttype = dataHelper.GetDataUrlAll("CleanBG", "d_sms", "type");
                                        if(!dataselecttype.sr.IsNullOrEmpty()&&!dataselecttype.sr.Id.IsNullOrEmpty()){
                                            if( dataselecttype.bs.selecttype=="1")
                                            {
                                                <select id='type' name="type" value="" class="form-control column selectpicker" data-live-search="true"  >
                                                    @foreach (DataRow rows in dataselecttype.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            
                                            }
                                            if( dataselecttype.bs.selecttype=="3")
                                            {
                                                <select id='type' name="type" value="" class="form-control column selectpicker" data-live-search="true" multiple >
                                                    @foreach (DataRow rows in dataselecttype.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            }
                                             if( dataselecttype.bs.selecttype=="2")
                                             {
                                                 string typename = @dataselecttype.sr.tablename.Split('.')[@dataselecttype.sr.tablename.Split('.').Length - 1];
                                                 string areaname = @dataselecttype.sr.tablename.Split('.')[@dataselecttype.sr.tablename.Split('.').Length - 3];
                                                 <input id='type__Name' name='type__Name' value='' onclick='openFormSelect("/@areaname/@typename","@dataselecttype.sr.filedcode,@dataselecttype.sr.filedvalue",this); ' type='text' class='form-control column'  readonly='readonly'/>
                                                 <input id='type' name='type' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                              }
                                             if( dataselecttype.bs.selecttype=="4")
                                             {
                                                 <div id='typeImg' style='width:100%; height:200px; overflow: auto'></div>
                                                 <input id='type__Name' name='type__Name' value='' type='hidden'  class='form-control column'  readonly='readonly'/>
                                                 <input id='type' name='type' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                                  @Html.Raw("<script>\n");
                                                  @Html.Raw("$(function(){\n");
                                                  @Html.Raw("$('#type__Img').html5Uploader({\n");
                                                  @Html.Raw("asyncUpload: true,\n");
                                                  @Html.Raw("uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                                  @Html.Raw($"uploadLimit: {dataselecttype.getPropValue("filenum")},  //上传数量限制，0为不限\n");
                                                  @Html.Raw($"sizeLimit:{dataselecttype.getPropValue("filesize")},    //大小限制，M\n");
                                                  @Html.Raw($"type: '{dataselecttype.getPropValue("filetype")}' //file即可上传文件也可上传图片\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("$('#type__Name').on(' input propertychange',function(){\n");
                                                  @Html.Raw("var urls = $(this).val().split(',');\n");
                                                  @Html.Raw("var ids = $('#type').val().split(',');\n");
                                                  @Html.Raw("$.each(urls, function(index, url){\n");
                                                  @Html.Raw("if(url!='')\n");
                                                  @Html.Raw("$('#type__Img').html5Uploader('insertItemNew',{src:url,id:ids[index]});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("</script>\n");
                                              }
                                        }
                                        else {
                                        <input id='type' name="type"  maxlength="50" value="" type="text" class="form-control column" >}}
                                </div>
                            </div>
                          <div class="form-group form-group-sm">
                        <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_phone","电话号码")</label>
                        <div class="col-sm-5">@{
                                        base_selectresource_data dataselectphone = dataHelper.GetDataUrlAll("CleanBG", "d_sms", "phone");
                                        if(!dataselectphone.sr.IsNullOrEmpty()&&!dataselectphone.sr.Id.IsNullOrEmpty()){
                                            if( dataselectphone.bs.selecttype=="1")
                                            {
                                                <select id='phone' name="phone" value="" class="form-control column selectpicker" data-live-search="true"  >
                                                    @foreach (DataRow rows in dataselectphone.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            
                                            }
                                            if( dataselectphone.bs.selecttype=="3")
                                            {
                                                <select id='phone' name="phone" value="" class="form-control column selectpicker" data-live-search="true" multiple >
                                                    @foreach (DataRow rows in dataselectphone.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            }
                                             if( dataselectphone.bs.selecttype=="2")
                                             {
                                                 string typename = @dataselectphone.sr.tablename.Split('.')[@dataselectphone.sr.tablename.Split('.').Length - 1];
                                                 string areaname = @dataselectphone.sr.tablename.Split('.')[@dataselectphone.sr.tablename.Split('.').Length - 3];
                                                 <input id='phone__Name' name='phone__Name' value='' onclick='openFormSelect("/@areaname/@typename","@dataselectphone.sr.filedcode,@dataselectphone.sr.filedvalue",this); ' type='text' class='form-control column'  readonly='readonly'/>
                                                 <input id='phone' name='phone' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                              }
                                             if( dataselectphone.bs.selecttype=="4")
                                             {
                                                 <div id='phoneImg' style='width:100%; height:200px; overflow: auto'></div>
                                                 <input id='phone__Name' name='phone__Name' value='' type='hidden'  class='form-control column'  readonly='readonly'/>
                                                 <input id='phone' name='phone' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                                  @Html.Raw("<script>\n");
                                                  @Html.Raw("$(function(){\n");
                                                  @Html.Raw("$('#phone__Img').html5Uploader({\n");
                                                  @Html.Raw("asyncUpload: true,\n");
                                                  @Html.Raw("uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                                  @Html.Raw($"uploadLimit: {dataselectphone.getPropValue("filenum")},  //上传数量限制，0为不限\n");
                                                  @Html.Raw($"sizeLimit:{dataselectphone.getPropValue("filesize")},    //大小限制，M\n");
                                                  @Html.Raw($"type: '{dataselectphone.getPropValue("filetype")}' //file即可上传文件也可上传图片\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("$('#phone__Name').on(' input propertychange',function(){\n");
                                                  @Html.Raw("var urls = $(this).val().split(',');\n");
                                                  @Html.Raw("var ids = $('#phone').val().split(',');\n");
                                                  @Html.Raw("$.each(urls, function(index, url){\n");
                                                  @Html.Raw("if(url!='')\n");
                                                  @Html.Raw("$('#phone__Img').html5Uploader('insertItemNew',{src:url,id:ids[index]});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("</script>\n");
                                              }
                                        }
                                        else {
                                        <input id='phone' name="phone"  maxlength="20" value="" type="text" class="form-control column" >}}
                                </div>
                            </div>
                          <div class="form-group form-group-sm">
                        <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_BizId","阿里云回执")</label>
                        <div class="col-sm-5">@{
                                        base_selectresource_data dataselectBizId = dataHelper.GetDataUrlAll("CleanBG", "d_sms", "BizId");
                                        if(!dataselectBizId.sr.IsNullOrEmpty()&&!dataselectBizId.sr.Id.IsNullOrEmpty()){
                                            if( dataselectBizId.bs.selecttype=="1")
                                            {
                                                <select id='BizId' name="BizId" value="" class="form-control column selectpicker" data-live-search="true"  >
                                                    @foreach (DataRow rows in dataselectBizId.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            
                                            }
                                            if( dataselectBizId.bs.selecttype=="3")
                                            {
                                                <select id='BizId' name="BizId" value="" class="form-control column selectpicker" data-live-search="true" multiple >
                                                    @foreach (DataRow rows in dataselectBizId.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            }
                                             if( dataselectBizId.bs.selecttype=="2")
                                             {
                                                 string typename = @dataselectBizId.sr.tablename.Split('.')[@dataselectBizId.sr.tablename.Split('.').Length - 1];
                                                 string areaname = @dataselectBizId.sr.tablename.Split('.')[@dataselectBizId.sr.tablename.Split('.').Length - 3];
                                                 <input id='BizId__Name' name='BizId__Name' value='' onclick='openFormSelect("/@areaname/@typename","@dataselectBizId.sr.filedcode,@dataselectBizId.sr.filedvalue",this); ' type='text' class='form-control column'  readonly='readonly'/>
                                                 <input id='BizId' name='BizId' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                              }
                                             if( dataselectBizId.bs.selecttype=="4")
                                             {
                                                 <div id='BizIdImg' style='width:100%; height:200px; overflow: auto'></div>
                                                 <input id='BizId__Name' name='BizId__Name' value='' type='hidden'  class='form-control column'  readonly='readonly'/>
                                                 <input id='BizId' name='BizId' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                                  @Html.Raw("<script>\n");
                                                  @Html.Raw("$(function(){\n");
                                                  @Html.Raw("$('#BizId__Img').html5Uploader({\n");
                                                  @Html.Raw("asyncUpload: true,\n");
                                                  @Html.Raw("uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                                  @Html.Raw($"uploadLimit: {dataselectBizId.getPropValue("filenum")},  //上传数量限制，0为不限\n");
                                                  @Html.Raw($"sizeLimit:{dataselectBizId.getPropValue("filesize")},    //大小限制，M\n");
                                                  @Html.Raw($"type: '{dataselectBizId.getPropValue("filetype")}' //file即可上传文件也可上传图片\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("$('#BizId__Name').on(' input propertychange',function(){\n");
                                                  @Html.Raw("var urls = $(this).val().split(',');\n");
                                                  @Html.Raw("var ids = $('#BizId').val().split(',');\n");
                                                  @Html.Raw("$.each(urls, function(index, url){\n");
                                                  @Html.Raw("if(url!='')\n");
                                                  @Html.Raw("$('#BizId__Img').html5Uploader('insertItemNew',{src:url,id:ids[index]});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("</script>\n");
                                              }
                                        }
                                        else {
                                        <input id='BizId' name="BizId"  maxlength="50" value="" type="text" class="form-control column" >}}
                                </div>
                            </div>
                        <div class="form-group form-group-sm">
                            <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_starttime","生效时间")</label>
                            <div class="col-sm-5">
                                <input readonly='readonly' id="starttime" name="starttime" data-date-format="yyyy-MM-dd HH:mm:ss" maxlength="1000" value="" type="text" class="form-control column" >
                                <div class="help-block with-errors"></div>
                            </div>
                             <script>
                                $('#starttime').datetimepicker({
                                //language: 'zh-CN',
                                //format:'yyyy-mm-dd hh:ii:ss',
                                //minView: 0,//日期选择
                                //autoclose:true,
                                //language:'zh-CN'
                                    minView: 'month', //选择日期后，不会再跳转去选择时分秒 
                                    language: 'zh-CN',
                                    format: 'yyyy-mm-dd',
                                    todayBtn: 1,
                                    autoclose: 1
                                });
                        </script>
                        </div>
                        <div class="form-group form-group-sm">
                            <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_endtime","失效时间")</label>
                            <div class="col-sm-5">
                                <input readonly='readonly' id="endtime" name="endtime" data-date-format="yyyy-MM-dd HH:mm:ss" maxlength="1000" value="" type="text" class="form-control column" >
                                <div class="help-block with-errors"></div>
                            </div>
                             <script>
                                $('#endtime').datetimepicker({
                                //language: 'zh-CN',
                                //format:'yyyy-mm-dd hh:ii:ss',
                                //minView: 0,//日期选择
                                //autoclose:true,
                                //language:'zh-CN'
                                    minView: 'month', //选择日期后，不会再跳转去选择时分秒 
                                    language: 'zh-CN',
                                    format: 'yyyy-mm-dd',
                                    todayBtn: 1,
                                    autoclose: 1
                                });
                        </script>
                        </div>
                          <div class="form-group form-group-sm">
                        <label class="col-sm-2 control-label">@TranslateService.GetTranslate("","CleanBG_d_sms_Remark","备注")</label>
                        <div class="col-sm-5">@{
                                        base_selectresource_data dataselectRemark = dataHelper.GetDataUrlAll("CleanBG", "d_sms", "Remark");
                                        if(!dataselectRemark.sr.IsNullOrEmpty()&&!dataselectRemark.sr.Id.IsNullOrEmpty()){
                                            if( dataselectRemark.bs.selecttype=="1")
                                            {
                                                <select id='Remark' name="Remark" value="" class="form-control column selectpicker" data-live-search="true"  >
                                                    @foreach (DataRow rows in dataselectRemark.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            
                                            }
                                            if( dataselectRemark.bs.selecttype=="3")
                                            {
                                                <select id='Remark' name="Remark" value="" class="form-control column selectpicker" data-live-search="true" multiple >
                                                    @foreach (DataRow rows in dataselectRemark.data.Rows)
                                                    {
                                                             <option value="@rows[0]" >@rows[1]</option>
                                                    }
                                                </select>
                                            }
                                             if( dataselectRemark.bs.selecttype=="2")
                                             {
                                                 string typename = @dataselectRemark.sr.tablename.Split('.')[@dataselectRemark.sr.tablename.Split('.').Length - 1];
                                                 string areaname = @dataselectRemark.sr.tablename.Split('.')[@dataselectRemark.sr.tablename.Split('.').Length - 3];
                                                 <input id='Remark__Name' name='Remark__Name' value='' onclick='openFormSelect("/@areaname/@typename","@dataselectRemark.sr.filedcode,@dataselectRemark.sr.filedvalue",this); ' type='text' class='form-control column'  readonly='readonly'/>
                                                 <input id='Remark' name='Remark' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                              }
                                             if( dataselectRemark.bs.selecttype=="4")
                                             {
                                                 <div id='RemarkImg' style='width:100%; height:200px; overflow: auto'></div>
                                                 <input id='Remark__Name' name='Remark__Name' value='' type='hidden'  class='form-control column'  readonly='readonly'/>
                                                 <input id='Remark' name='Remark' value=''  type='hidden' class='form-control column'  readonly='readonly'/>
                                                  @Html.Raw("<script>\n");
                                                  @Html.Raw("$(function(){\n");
                                                  @Html.Raw("$('#Remark__Img').html5Uploader({\n");
                                                  @Html.Raw("asyncUpload: true,\n");
                                                  @Html.Raw("uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                                  @Html.Raw($"uploadLimit: {dataselectRemark.getPropValue("filenum")},  //上传数量限制，0为不限\n");
                                                  @Html.Raw($"sizeLimit:{dataselectRemark.getPropValue("filesize")},    //大小限制，M\n");
                                                  @Html.Raw($"type: '{dataselectRemark.getPropValue("filetype")}' //file即可上传文件也可上传图片\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("$('#Remark__Name').on(' input propertychange',function(){\n");
                                                  @Html.Raw("var urls = $(this).val().split(',');\n");
                                                  @Html.Raw("var ids = $('#Remark').val().split(',');\n");
                                                  @Html.Raw("$.each(urls, function(index, url){\n");
                                                  @Html.Raw("if(url!='')\n");
                                                  @Html.Raw("$('#Remark__Img').html5Uploader('insertItemNew',{src:url,id:ids[index]});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("});\n");
                                                  @Html.Raw("</script>\n");
                                              }
                                        }
                                        else {
                                        <input id='Remark' name="Remark"  maxlength="255" value="" type="text" class="form-control column" >}}
                                </div>
                            </div>
         @{
            List<base_extendedfield> exs = dataHelper.GetExFileds("CleanBG", "d_sms");
            foreach (var ex in exs)
            {
                <div class='form-group form-group-sm'>
                <label class='col-sm-2 control-label'>@TranslateService.GetTranslate("", $@"CleanBG_d_sms_{ex.exfiled}", $@"{ex.filedname}")</label>
                    <div class='col-sm-5'>
                            @{base_selectresource_data dataselect = dataHelper.GetDataUrlAll("CleanBG", "d_sms", $@"{ex.exfiled}");
                                if (!dataselect.sr.IsNullOrEmpty() && !dataselect.sr.Id.IsNullOrEmpty())
                                {
                                    if (dataselect.bs.selecttype == "1")
                                    {
                                        <select id='@ex.exfiled' name='@ex.exfiled' value='' class='form-control column selectpicker' data-live-search='true'>
                                            @foreach (DataRow rows in dataselect.data.Rows)
                                            {
                                                 <option value='@rows[0]'>@rows[1]</option>
                                            }
                                        </select>

                                    }
                                    @if(dataselect.bs.selecttype == "3")
                                    {
                                        <select id='@ex.exfiled' name='@ex.exfiled' value='' class='form-control column selectpicker' data-live-search='true' multiple>
                                            @foreach (DataRow rows in dataselect.data.Rows)
                                            {
                                                <option value='@rows[0]'>@rows[1]</option>
                                            }
                                        </select>
                                    }
                                    if (dataselect.bs.selecttype == "2")
                                    {
                                        string typename = dataselect.sr.tablename.Split('.')[dataselect.sr.tablename.Split('.').Length - 1];
                                        string areaname = dataselect.sr.tablename.Split('.')[dataselect.sr.tablename.Split('.').Length - 3];
                                        <input readonly='readonly' id='@ex.exfiled;__Name' name='{@ex.exfiled}__Name' value='' onclick='openFormSelect('/@areaname/@typename','@dataselect.sr.filedcode,@dataselect.sr.filedvalue',this); ' type='text' class='form-control column' readonly='readonly'>
                                        <input readonly='readonly' id='@ex.exfiled' name='{@ex.exfiled}' value='' type='hidden' class='form-control column' readonly='readonly'>
                                    }
                                    if (dataselect.bs.selecttype == "4")
                                    {
                                        <div id='@ex.exfiled;__Img' style='width:100%; height:200px; overflow: auto'></div>
                                        <input id='@ex.exfiled;__Name' name='@ex.exfiled;__Name' value='' type='hidden' class='form-control column' readonly='readonly' />
                                        <input id='@ex.exfiled' name='@ex.exfiled' value='' type='hidden' class='form-control column' readonly='readonly' />
                                        @Html.Raw($@"<script>\n");
                                        @Html.Raw($@"$(function(){{\n");
                                        @Html.Raw($@"$('#{ex.exfiled}__Img').html5Uploader({{\n");
                                        @Html.Raw($@"asyncUpload: true,\n");
                                        @Html.Raw($@"uploadUrl: '/Base_SysManage/Common/UploadFile',\n");
                                        @Html.Raw($@"uploadLimit: 0,  //上传数量限制，0为不限\n");
                                        @Html.Raw($@"sizeLimit: 5,    //大小限制，M\n");
                                        @Html.Raw($@"type: 'file' //file即可上传文件也可上传图片\n");
                                        @Html.Raw($@"}});\n");
                                        @Html.Raw($@"$('#{ex.exfiled}__Name').trigger('propertychange');}});\n");
                                        @Html.Raw($@"$('#{ex.exfiled}__Name').on(' input propertychange',function(){{\n");
                                        @Html.Raw($@"var urls = $(this).val().split(',');\n");
                                        @Html.Raw($@"var ids = $('#{ex.exfiled}').val().split(',');\n");
                                        @Html.Raw($@"$.each(urls, function(index, url){{\n");
                                        @Html.Raw($@"if(url!='')\n");
                                        @Html.Raw($@"$('#{ex.exfiled}__Img').html5Uploader('insertItemNew',{{src:url,id:ids[index]}});\n");
                                        @Html.Raw($@"}});\n");
                                        @Html.Raw($@"}});\n");
                                        @Html.Raw($@"</script>\n");
                                    }
                                }
                                else
                                {
                                    <input id='@ex.exfiled' name='@ex.exfiled' maxlength='100' value='' type='text' class='form-control column'>
                                }
                            }
                    </div>
                </div>
             }
        }
        <div class="form-group">
            <button id="submit" type="submit" class="hidden">@TranslateService.GetTranslate("","System_Submit","提交")</button>
        </div>
    </form>
</div>
<script>
     var guid ='@guid';
     var key ='@key';
     var value ='@value';
     var data = JSON.parse(sessionStorage.getItem("d_sms"+guid));
     var rownum = @rownum;
     if (rownum >= 0)
     {
                for (i in data.rows[rownum])
                {
                    if ($("[name='" + i + "']").is ('.selectpicker')) {
                    $("[name='" + i + "']").selectpicker("val", data.rows[rownum][i].split(",")).trigger("propertychange");
                } else
                {
                $("[name='" + i + "']").val(data.rows[rownum][i]).trigger("propertychange");
                }
            }
        }

    $(function () {
        initEvent();
        $('#'+key).attr("required",false);
        $('#'+key).attr("readonly","readonly");
    });

    //事件绑定
    function initEvent() {
        //表单校验
        $('#form').validator().on('submit', function (e) {
            //校验成功
            if (!e.isDefaultPrevented()) {
                e.preventDefault();

                var values = $('#form').getValues();
                    var theEntity=values;
                    for (var item in theEntity){
                            if(theEntity[item]!=null)
                            theEntity[item] = theEntity[item].toString();
                    }
                    loading();
                    if (rownum >= 0) {
                        theEntity['ck'] = true;
                        if (data == null) {
                            data = {};
                            data['rows'] = new Array();
                        }
                        for (var item in theEntity){
                            data.rows[rownum][item] = theEntity[item];
                        }
                    }
                    else {
                        theEntity['ck'] = true;
                        if (data == null) {
                            data = {};
                            data['rows'] = new Array();
                        }
                        data.rows.push(theEntity);
                    }
                    sessionStorage.setItem("d_sms"+guid, JSON.stringify(data));
                    dialogClose();
            }
        })
    }

    //提交表单
    function submitForm() {
        $('#submit').trigger('click');
    }
     $(function () {
        $('#WorkerContractImg').html5Uploader({
            //imgs: theEntity[aImgId],
            asyncUpload: true,
            uploadUrl: '/Base_SysManage/Common/UploadFile',
            uploadLimit: 0,  //上传数量限制，0为不限
            sizeLimit: 5,    //大小限制，M
            type:'file' //file即可上传文件也可上传图片
        });
    });

    
    //手写文字识别
    function OCRForm() {
        //获取上传后的url
        var url = $('#WorkerContractImg').html5Uploader('getUploadFiles');
        //console.log(url);   
        // 返回 web 主机的域名，如：http://127.0.0.1:8080/testdemo/test.html?id=1&name=test
        var href = window.location.href; 
        // 返回当前页面的路径和文件名，如：/testdemo/test.html
        var pathname = window.location.pathname;
        pathname = href.replace(pathname, "");
        // 获取参数，如：?id=1&name=test
        var search = window.location.search;
        pathname = pathname.replace(search, "") + " / ";


        url = (String(url)).replace(pathname, "");
            url = url.replace(/\//g, "\\");


            loading();
        $.postJSON('/Visit/visit_type_authorize/OCRData', { FileName: (url) }, function (resJson) {
                //loading(false);
                if (resJson.Success) {
                   $table.bootstrapTable('refresh');
                    dialogSuccess('表单识别成功!');
                }
                else {
                    dialogError(resJson.Msg);
                }
            });       
    }
    //语音识别输入
    function speech() {
    alert('功能完善中');
    }
 
    
    function openFormSelect(modelurl,returnkey,obj) {
        dialogOpen({
            id: 'form1',
            title: '@TranslateService.GetTranslate("","System_Select","选择")',
            btn: ['@TranslateService.GetTranslate("","System_Confirm","确定")', '@TranslateService.GetTranslate("","System_Cancel","取消")'],
            height: '80%',
            url: modelurl + '/GetIndex?returnkey=' + returnkey,
            yes: function(window, index) {
                 $(obj).val(window.chekcName);
                 $(obj).next().val(window.chekcCode).trigger("propertychange");
                 dialogClose("form1");
            }
        });
    }
</script>
